//
//  AppDelegate.h
//  JCSwizzle
//
//  Created by chun on 2018/5/23.
//  Copyright © 2018年 JC. All rights reserved.
//

#import "ViewController+hook.h"
#import <objc/runtime.h>
#import "NSObject+Swizzle.h"


static char *enterCountKey = "enterCountKey";

@implementation ViewController (hook)
+ (void)load {
    [self exchangeOriginMethod:@selector(viewDidLoad) newMethod:@selector(jc_viewDidLoad)];
}

- (void)jc_viewDidLoad {
    NSString *str = [NSString stringWithFormat:@"%@", self.class];
    if(![str containsString:@"UI"]){
        NSLog(@"统计打点 : %@", self.class);
    }
    
    self.enterCount = 0;
    [self jc_viewDidLoad];
}

- (void)setEnterCount:(NSInteger)enterCount {
    NSString *countString = [NSString stringWithFormat:@"%ld", enterCount];
    objc_setAssociatedObject(self, enterCountKey, countString, OBJC_ASSOCIATION_COPY_NONATOMIC);
}

- (NSInteger)enterCount {
    return  [objc_getAssociatedObject(self, enterCountKey) integerValue];
}
@end
